/**
 * 属性特征分类开窗
 * @author wenchuan.li
 * @date 2019/01/16
 */
define(function () {

    var self,
        app = win.app,
        vueData = {
            tableData: [],
            count: 0,
            limit: 10,
            keyword: '',
            GWAM001: '',
            GWAM005: '',
            GWAM006: ''
        },
        page = 1,cb
    ;

    app.newModule({
        init: function () {
            self = this;
            self._super({
                _tag: 'common_open_sxtz',
                _loadTplsFull: [{
                    dom: 'gwai500_1_edit', tpl: 'gwai500_1_edit'
                }]
            }, win);
        },
        queryDatas: function () {
            app.ajax({
                xurl: 'crm/gwai260/getList',
                xdata: {
                    page: page,
                    limit: vueData.limit,
                    keyword: vueData.keyword,
                    GWAM005: vueData.GWAM005,
                    GWAM006: vueData.GWAM006,
                    GWAM001: vueData.GWAM001
                },
                cb: function (result) {
                    if (result.ok) {
                        vueData.tableData.pushArray(result.data.data, true);
                        vueData.count = result.data.count;
                    }
                }
            });
        },

        _call: function (obj) {
            vueData.GWAM001 = obj.GWAM001;
            cb = obj.cb;
            vueData.keyword = '';
            vueData.GWAM005 = obj.GWAM005;
            vueData.GWAM006 = obj.GWAM006;
            self.queryDatas();
        },


        _ready: function () {
            new Vue({
                el: '#common_open_sxtz',
                data: vueData,
                methods: {
                    selectRow: function (inx, row) {
                        layer.close(layer.index);
                        if(vueData.GWAM001 != '') {
                            self._openTplFull({
                                tag: 'gwai500_1_edit',
                                tagData: {
                                    is_add: true,
                                    GWAN001: vueData.GWAM001,
                                    GWAN002: row.GWAI001,
                                    GWAIL003: row.GWAIL003
                                },
                                index: 0,
                                openOpts: {
                                    title: '产品属性特征资料新增',
                                    area: ["600px", "400px"]
                                }
                            });
                        }else{
                           cb(row);
                        }
                    },
                    handleSizeChange: function (val) {
                    },
                    handleCurrentChange: function (val) {
                        page = val;
                        self.queryDatas();
                    },
                    queryDatas: function () {
                        page = 1;
                        self.queryDatas();
                    }
                },
                created: function () {
                    self._setEleIsReady('common_open_sxtz');
                }
            });
        },

        _lazy: function () {
            this._super();
        }
    });

});